using System.Configuration;

namespace KexpScrobbler
{
    public class KexpScrobblerConfigurationSection : ConfigurationSection
    {
        static ConfigurationProperty passwordProperty;
        static ConfigurationProperty balloonProperty;
        static ConfigurationProperty usernameProperty;

        static ConfigurationPropertyCollection properties;

        static KexpScrobblerConfigurationSection()
        {
            usernameProperty = new ConfigurationProperty("username", typeof(string),
                            null, ConfigurationPropertyOptions.None);

            passwordProperty = new ConfigurationProperty("password", typeof(string),
                            null, ConfigurationPropertyOptions.None);

            balloonProperty = new ConfigurationProperty("balloon", typeof(bool),
                            true, ConfigurationPropertyOptions.None);

            properties = new ConfigurationPropertyCollection();

            properties.Add(balloonProperty);
            properties.Add(usernameProperty);
            properties.Add(passwordProperty);
        }

        protected override ConfigurationPropertyCollection Properties
        {
            get { return properties; }
        }

        #region Configuration properties

        [ConfigurationProperty("username", IsRequired = false)]
        public string Username
        {
            get { return (string)base[usernameProperty]; }
            set { base[usernameProperty] = value; }
        }

        [ConfigurationProperty("balloon", IsRequired = false)]
        public bool Balloon
        {
            get { return (bool)base[balloonProperty]; }
            set { base[balloonProperty] = value; }
        }


        [ConfigurationProperty("password", IsRequired = false)]
        public string Password
        {
            get { return (string)base[passwordProperty]; }
            set { base[passwordProperty] = value; }
        }

        #endregion

        #region Properties

        public static ConfigurationProperty UsernameProperty
        {
            get { return KexpScrobblerConfigurationSection.usernameProperty; }
        }

        public static ConfigurationProperty PasswordProperty
        {
            get { return KexpScrobblerConfigurationSection.passwordProperty; }
        }

        public static ConfigurationProperty BalloonProperty
        {
            get { return KexpScrobblerConfigurationSection.balloonProperty; }
        }

        #endregion
    }
}
